package com.mxpio.erp.common.asset.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;

import com.mxpioframework.security.entity.Dept;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_ASSET_BR")
@Schema(description = "借还申请单")
public class BorrowApply  extends BaseEntity {
	private static final long serialVersionUID = 1L;
	
/*	@Id
	@Generator
	@Column(name = "ID_", updatable = false)
	@Schema(value = "ID")
	private String id;*/
/*	@Id
	@Column(name = "APPLY_NO_", updatable = false, unique = true)
	@Schema(description = "申请单号")
	private String applyNo;*/

	@Id
	@Column(name = "BIZ_NO_", updatable = false)
	@Schema(description = "申请单号")
	private String bizNo;
	
	@Column(name = "BPMN_STATUS_")
	@Schema(description = "审核状态")
	@Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
	private String bpmnStatus;
	
/*	@Column(name = "APPLY_STATUS_")
	@Schema(value = "执行状态")
	@Dict(dicCode = "ERP_COMMON_ORDER_STATUS")
	private String applyStatus;*/

	@Column(name = "RETURN_STATUS_")
	@Schema(description = "归还状态")
	@Dict(dicCode = "ERP_ASSET_BORROW_RETURN_STATUS")//
	private String returnStatus;

	@Column(name = "ORDER_STATUS_")
	@Schema(description = "执行状态")
	@Dict(dicCode = "ERP_COMMON_ORDER_STATUS")
	private String orderStatus;
	
	@Column(name = "CLOSE_STATUS_")
	@Schema(description = "关闭状态")
	@Dict(dicCode="ERP_COMMON_CLOSE_STATUS")
	private String closeStatus;

	/*@Column(name = "apply_type_")
	@Schema(description = "申请类型(0借出/1归还)")*/
	@Transient
	private String applyType;//申请类型(0借出/1归还)
	
	@Column(name = "BORROWER_")
	@Schema(description = "借用人")
	private String borrower;
	
	@Column(name = "BORROW_TIME_")
	@Schema(description = "借出时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date borrowTime;
	
	@Column(name = "BORROW_POSITION_")
	@Schema(description = "借用位置")
	private String borrowPosition;

	@Column(name = "APPLY_DEPT_")
	@Schema(description = "申请部门")
	@Dict(dicCode = "deptCode", dicEntity = Dept.class, dicText = "deptName")
	private String applyDept;
	
	@Column(name = "PLAN_RETURN_TIME_")
	@Schema(description = "预计归还时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date planReturnTime;
	
	@Column(name = "ACTUAL_RETURN_TIME_")
	@Schema(description = "归还时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date actualReturnTime;
	
	@Column(name = "REVIEWER_")
	@Schema(description = "审核人")
	private String reviewer;

	@Column(name = "REVIEW_TIME_")
	@Schema(description = "审核时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date reviewTime;
	
	@Column(name = "EXECUTOR_")
	@Schema(description = "执行人")
	private String executor;
	
	@Column(name = "EXECUTE_TIME_")
	@Schema(description = "执行时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date executeTime;
	
	@Column(name = "MEMO_")
	@Schema(description = "备注")
	private String memo;

	@Column(name = "WH_CODE_")
	@Schema(description = "仓库编号")
	private String whCode;

	@Transient
	private List<BorrowApplyLine> borrowApplyLines;
	
}
